package com.lzy.pattern.facade;

/**
 * @ClassName: SmartApplicationsFacade
 * @Description: TODO
 * @Author: LiuZy
 * @Date: 2022/4/24 20:41
 * @Version: 1.0
 */
public class SmartApplicationsFacade {

    private Light light;
    private Tv tv;
    private AirConditioner airConditioner;

    public SmartApplicationsFacade(){
        this.light = new Light();
        this.tv = new Tv();
        this.airConditioner = new AirConditioner();
    }

    public void say(String msg){
        if("打开".equals(msg)){
            on();
        }else if("关闭".equals(msg)){
            off();
        }else{
            throw new RuntimeException("没听清，请再说一遍。。");
        }
    }

    public void on() {
        light.on();
        tv.on();
        airConditioner.on();
    }

    public void off() {
        light.off();
        tv.off();
        airConditioner.off();
    }

}